package com.aaa.dem1107.d03;

/**
 * @Author: whj
 * @Version 1.0
 * @Date: 2022/11/7  10:32
 */

    /**
     * 懒汉式
     */
public class Singleton1 {
        //第一步
        private Singleton1() {}
        //声明一个静态的本类对象----懒汉式
        private static Singleton1 singleton1;
        //提供一个静态方法返回本类的对象
        public static Singleton1 getInstance() {
            if (singleton1 == null) {
                singleton1 = new Singleton1();
            }
            return singleton1;
        }
        public void show() {
            System.out.println("~~~~~~~~~~~~~~~~~~~~~show方法~~~~~~~~~~~~~~~");
        }
}
